package api

import (
	"github.com/labstack/echo/v4"
	"longmen/server/config/global"
	"longmen/server/pkg/common/api_models"
	"longmen/server/pkg/common/helper/const"
	"longmen/server/pkg/common/helper/util"
	"net/http"
)

// GetMatchText
// @Summary 赛事資訊 - 文字分頁
// @Description 查询歷史文字資訊
// @Accept  json
// @Produce  json
// @Tags 文字分頁
// @Param   sendBody body api_models.GetTextLiveReq true "body"
// @Success 200 {object} []messages.TextLiveStruct "result"
// @Router /api/matchLive/text [POST]
func (base *Controller) GetMatchText(c echo.Context) (err error) {
	r := &api_models.GetTextLiveReq{}
	if err = util.Json2Struct(c.Get("body").(string), r); err != nil {
		return util.BadParam(c, err)
	}
	if err = _const.Validate.Struct(r); err != nil {
		global.Log.Errorf("6IdentityAuth9", err)
		return util.BadParam(c, err)
	}
	r.Size = 30
	result := base.Service.GetMatchTextService(r)
	if len(result) == 0 {
		global.Log.Debugf("GetMatchText err : %v", err)
		return c.JSON(http.StatusBadRequest, err)
	}
	return c.JSON(http.StatusOK, result)
}
